package com.lottery.api.controller.member;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.lottery.api.annotation.CheckLoginAop;
import com.lottery.api.service.MemberInfoService;
import com.lottery.common.contants.ReQueryResult;
import com.lottery.common.entity.*;
import com.lottery.common.service.FocusMemberRecordService;
import com.lottery.common.service.ForecastInfoService;
import com.lottery.common.service.MemberInfoSubService;
import com.lottery.common.service.NewsFlashInfoService;
import com.lottery.common.utils.RedisUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.nutz.lang.util.NutMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

import javax.servlet.http.HttpServletRequest;

import java.util.List;

import static com.lottery.common.contants.Constants.*;

@RestController
@RequestMapping("/memberSub")
@Slf4j
//@Api(value = "/memberSub",tags="会员操作副类")
public class MemberInfoSubController {
    private ReQueryResult result = new ReQueryResult();


    @Autowired
    private MemberInfoService mis;

    @Autowired
    private MemberInfoSubService miss;
    @Autowired
    private NewsFlashInfoService newsFlashInfoService;
    @Autowired
    private ForecastInfoService forecastInfoService;
    @Autowired
    private FocusMemberRecordService focusMemberRecordService;


//
//    @ApiOperation(value = "首页 第二页")
//    @RequestMapping(value = "/indexSub", method = RequestMethod.POST)
//    public ReQueryResult ranking()  {
//        result=new ReQueryResult();
//
//        //大神排行
//        NutMap nutMap=new NutMap();
//        nutMap.setv("type",TYPE_ONE);
//        nutMap.setv("identify",TYPE_ONE);
//        nutMap.setv("startNum",TYPE_THREE);
//        List<MemberInfoSub> subList=miss.selectSubList(nutMap);
//
//        //专号推荐
//        QueryWrapper<ForecastInfo> fQueryWrapper=new QueryWrapper<>();
//        fQueryWrapper.eq("type",TYPE_ONE).eq("recommend",TYPE_ZERO).orderByDesc("id");
//        List<ForecastInfo> fList=forecastInfoService.list(fQueryWrapper);
//        StringBuilder sb=new StringBuilder("");
//        String str="";
//        for (ForecastInfo info:fList){
//            sb.append(str).append(info.getMemberId());
//            str=",";
//        }
//        nutMap=new NutMap();
//        nutMap.setv("ids",sb.toString());
//        List<MemberInfoSub> slist2=miss.selectSubList(nutMap);
//        for (ForecastInfo info:fList){
//            for (MemberInfoSub sub:slist2){
//                if (info.getMemberId().equals(sub.getMemberId())) {
//                    info.setMemberSub(sub);
//                }
//            }
//        }
//
//        //热门资讯
//        QueryWrapper<NewsFlashInfo> queryWrapper=new QueryWrapper<>();
//        queryWrapper.orderByDesc("id").last(" limit 3");
//        List<NewsFlashInfo> newsList=newsFlashInfoService.list(queryWrapper);
//
//
//
//        NutMap map=new NutMap();
//        map.setv("sub",subList);
//        map.setv("news",newsList);
//
//        result.success(SUCCESS_DESC);
//        return  result;
//    }
//
//
//
//
//    @ApiOperation(value = "01排行")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "type",value = "1胜率 2盈利率 3 连红 ",dataType="Integer"),
//            @ApiImplicitParam(name = "index",value = "页码 ",dataType="Integer"),
//            @ApiImplicitParam(name = "length",value = "长度",dataType="Integer")
//    })
//    @RequestMapping(value = "/ranking", method = RequestMethod.POST)
//    public ReQueryResult ranking(HttpServletRequest request,  Integer type,
//                         Integer index,Integer length) throws Exception {
//        result=new ReQueryResult();
//        NutMap nutMap=new NutMap();
//        nutMap.setv("type",type);
//        nutMap.setv("identify",TYPE_ZERO);
//        nutMap.setv("startNum",nutMap.getInt("pageLength")*(nutMap.getInt("pageIndex")-1))
//        .setv("endNum",nutMap.getInt("pageLength"));
//        List<MemberInfoSub> subList=miss.selectSubList(nutMap);
//        result.setData(subList);
//        result.success(SUCCESS_DESC);
//        return  result;
//    }
//
//    @ApiOperation(value = "搜索大神")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "type",value = "1胜率 2盈利率 3 连红 ",dataType="Integer"),
//            @ApiImplicitParam(name = "index",value = "页码 ",dataType="Integer"),
//            @ApiImplicitParam(name = "length",value = "长度",dataType="Integer")
//    })
//    @RequestMapping(value = "/search", method = RequestMethod.POST)
//    @CheckLoginAop
//    public ReQueryResult search(HttpServletRequest request, @ApiIgnore() MemberInfo memberInfo, Integer type,
//                                Integer index, Integer length) throws Exception {
//        result=new ReQueryResult();
//        NutMap nutMap=new NutMap();
//
//        nutMap.setv("startNum",nutMap.getInt("pageLength")*(nutMap.getInt("pageIndex")-1))
//                .setv("endNum",nutMap.getInt("pageLength"));
//        List<NutMap> flist=focusMemberRecordService.selectFocuseList(nutMap);
//
//
////        //focus 0 已关注 1未关注 2 互相关注
////        Integer focus=TYPE_ONE;
////        if (flist.size()>0){
////            NutMap map=flist.get(0);
////            if (map.getInt("count")>=1) {
////                focus=TYPE_ZERO;
////            }
////            if (map.getInt("subCount")>=1) {
////                focus=TYPE_TWO;
////            }
////        }
//        result.setData(flist);
//        result.success(SUCCESS_DESC);
//        return  result;
//    }

}
